﻿<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Bezdelnick
 * Date: 16.03.13
 * Time: 11:21
 * To change this template use File | Settings | File Templates.
 */
class Config
{
    private $dbConnection;

    private $dbHost = "localhost:3306";
    private $dbUserName = "root";
    private $dbPassword = "12345";
    private $dbName = "db_vs";

    private $basePath="video-store";

    private static $_instance;

    private function __construct()
    {
    }

    public static function getInstance()
    {
        if (!self::$_instance) {
            self::$_instance = new Config();
        }
        return self::$_instance;
    }

    public function getDbConnection()
    {
        // Connect to MySql Server
        if (!$this->dbConnection) {
            $this->dbConnection = mysql_connect($this->getDbHost(),
                $this->getDbUserName(),
                $this->getDbPassword()) OR DIE("Не могу создать соединение ");
            mysql_select_db($this->getDbName()) or die(mysql_error());
        }
        return $this->dbConnection;
    }

    public function setDbHost($dbServer)
    {
        $this->dbHost = $dbServer;
    }

    public function getDbHost()
    {
        return $this->dbHost;
    }

    public function setDbUserName($dbUserName)
    {
        $this->dbUserName = $dbUserName;
    }

    public function getDbUserName()
    {
        return $this->dbUserName;
    }

    public function setDbPassword($dbPassword)
    {
        $this->dbPassword = $dbPassword;
    }

    public function getDbPassword()
    {
        return $this->dbPassword;
    }

    public function setDbName($dbName)
    {
        $this->dbName = $dbName;
    }

    public function getDbName()
    {
        return $this->dbName;
    }

    public function getBasePath()
    {
        return $_SERVER["DOCUMENT_ROOT"];// . $this->basePath;
    }
}
